home *** CD-ROM | disk | FTP | other *** search
Text File | 1987-11-13 | 2.4 KB | 71 lines | [TEXT/MSWD] |
- Date Sat, 31 Oct 87 16 55 27 EST
- From Andrew Gilmartin <ANDREW%BROWNVM.BITNET@forsythe.stanford.edu>
- Subject Open and Save dialogs for HyperCard
-
- The stack below contains two simple XFunctions to facilitate interaction
- with disk files.
-
- The first, FileName, is a simple rewrite of the Steve Maller's XFunction
- of the same name. FileName allows the HyperTalk script writer to query
- the user for the name of an existing file.
-
- The second, NewFileName, allows the script writer to query the user for
- the name of a new file.
-
- These two XFunctions, while using the Macintosh standard file package,
- do depart from the standard human interface guidelines as they center
- the respective dialog box over the HyperCard window rather than the
- Macintosh Screen.
-
- I have chosen to do this as I feel that it clearly indicates that the
- dialog is a result of an interaction with the card rather than with
- HyperCard itself, or some other application if you are running in the
- Multifinder environment. (I wish I could do this with HyperTalk's ask
- and answer commands.)
-
- A typical script for FileName() would be
-
- -- FileName( <file type> )
-
- on mouseUp
- put FileName( "TEXT" ) into sourcefile
- if sourcefile is not empty then
- open file sourcefile
- -- read text from source file
- close file sourcefile
- end if
- end mouseUp
-
- The one optional parameter, <file type>, allows the script writer to
- display only files of a particular kind, such as text files or
- applications. Typical file types are "STAK" for HyperCard stacks,
- "TEXT" for simple text files, and "APPL" for applications.
-
- Unfortunately, sources for the names of other file types is limited
- without access to utilities such as ResEdit or MacSnoop.
-
- A typical script for NewFileName would be
-
- -- NewFileName( <prompt>, <initial FileName> )
-
- on mouseUp
- put NewFileName("Save document as?","") into targetfile
- if targetfile is not empty then
- -- write text to target file
- end if
- end mouseUp
-
- The first required parameter, <prompt>, should be a simple descriptive
- statement about the request, such as, "Save document as?," or "Save test
- result to ."
-
- The second required parameter is <initial FileName>. The first time
- NewFileName is called this should be empty ("") as the user is saving
- an untitled document. Thereafter, it should contain the name of the
- document as previously given by the user.
-
- I hope these will be of use.
-
- Andrew Gilmartin
- Brown University
-